<html>
<head><meta charset="utf-8"><title>lifetime label shadowing · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/lifetime.20label.20shadowing.html">lifetime label shadowing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223009624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/lifetime%20label%20shadowing/near/223009624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/lifetime.20label.20shadowing.html#223009624">(Jan 16 2021 at 22:16)</a>:</h4>
<p>Is there a reason this generates a warning about the label shadowing the lifetime?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">example</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="o">'</span><span class="na">a</span>: <span class="nc">loop</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="kt">u32</span> <span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="k">break</span><span class="w"> </span><span class="nl">'a</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>AFAICT, lifetimes in type expressions always use the lifetime declared in the generic parameters, and <code>break</code> and <code>continue</code> always uses labels (it never confuses them with lifetimes).  In other words, it seems like in practice they live in completely separate namespaces.  What am I missing?</p>



<a name="223009780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/lifetime%20label%20shadowing/near/223009780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/lifetime.20label.20shadowing.html#223009780">(Jan 16 2021 at 22:20)</a>:</h4>
<p>Last time I looked into it, I found the following: <a href="https://github.com/rust-lang/rust/issues/21633">https://github.com/rust-lang/rust/issues/21633</a></p>



<a name="223010288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/lifetime%20label%20shadowing/near/223010288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/lifetime.20label.20shadowing.html#223010288">(Jan 16 2021 at 22:30)</a>:</h4>
<p>Hm, so this looks like it was some kind of attempt at future-proofing. I should have run <code>git blame</code> first, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>